import 'package:flutter/material.dart';
import 'package:ref/ref.dart';
import '../main.dart';

// 旅游套餐列表
class TourList extends StatelessWidget {
  const TourList({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    var tempList = rootStore.tour.getTourList();
    return RefBuilder(() {
      if (tempList.value.length == 0)
        return Center(
          child: Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [Icon(Icons.rotate_right), Text('loading...2s后刷新！')],
          ),
        );
      return Column(
        children: tempList.value.map((e) {
          return Card(
            child: GestureDetector(
              onTap: () => rootStore.users.choiceTour(e),
              child: ListTile(
                leading: FlutterLogo(size: 50.0),
                title: Text(e.title + '  ¥' + e.price.toString(), maxLines: 2),
                subtitle: Text(e.desc, maxLines: 2),
                trailing: Icon(Icons.more_vert),
                isThreeLine: true,
              ),
            ),
          );
        }).toList(),
      );
    });
  }
}
